#include <iostream>
#include <vector>

using namespace std;

// 2266. 统计打字方案数
// https://leetcode.cn/problems/count-number-of-texts/description/

class Solution
{
    static const int MOD = 1e9 + 7;
    static const int maxLen = 1e5 + 1;

public:
    int countTexts(string pressedKeys)
    {
        vector<long long> threeDp(maxLen);
        vector<long long> fourDp(maxLen);
        // 初始化
        [&]()
        {
            threeDp[0] = 1;
            threeDp[1] = 1;
            threeDp[2] = 2;
            threeDp[3] = 4;
            fourDp[0] = 1;
            fourDp[1] = 1;
            fourDp[2] = 2;
            fourDp[3] = 4;

            for (int i = 4; i < maxLen; i++)
            {
                threeDp[i] = (threeDp[i - 1] + threeDp[i - 2] + threeDp[i - 3]) % MOD;
                fourDp[i] = (fourDp[i - 1] + fourDp[i - 2] + fourDp[i - 3] + fourDp[i - 4]) % MOD;
            }
        }();

        long long ans = 1;
        int cnt = 0;
        for (int i = 0; i < pressedKeys.size(); i++)
        {
            char curCh = pressedKeys[i];
            cnt++;
            if (i == pressedKeys.size() - 1 || pressedKeys[i + 1] != curCh)
            {
                ans = (ans * (curCh != '7' && curCh != '9' ? threeDp[cnt] : fourDp[cnt])) % MOD;
                cnt = 0;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}